package com.itheima.controller;

import com.itheima.entity.AccountAuthentication;
import com.itheima.entity.AccountNotification;
import com.itheima.entity.CertificationRules;
import com.itheima.result.PageResult;
import com.itheima.service.IAccountAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.itheima.utils.Result;

/**
 * 用户认证Controller
 *
 * @author guanhuaer
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/authentication")
public class AccountAuthenticationController
{
    @Autowired
    private IAccountAuthenticationService accountAuthenticationService;

    /**
     * 查询用户认证列表
     */
    @GetMapping("/list")
    public Result<PageResult> authenticationList(AccountAuthentication accountAuthentication){
        PageResult pageResult = accountAuthenticationService.selectAccountAuthenticationList(accountAuthentication);
        return Result.success(pageResult);
    }
    /**
     * 获取用户认证详细信息
     */
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(accountAuthenticationService.selectAccountAuthenticationById(id));
    }
    // 根据用户id获取用户认证详细信息
    @GetMapping(value = "/info")
    public Result getUserAuthentication(@RequestParam Long userId)
    {
        return Result.success(accountAuthenticationService.selectAccountAuthenticationByUserId(userId));
    }


    /**
     * 根据用户id获取用户信息通知详细信息
     */
    @GetMapping(value = "/notification")
    public Result getUserAccountNotification(AccountNotification notification)
    {
        return Result.success(accountAuthenticationService.selectAccountNotificationByUserId(notification.getUserId()));
    }
    /*
     * 根据id修改用户信息通知
     */
    @PutMapping("/notification")
    public Result  notificationEdit(@RequestBody AccountNotification notification)
    {
        return Result.success(accountAuthenticationService.updateAccountNotification(notification));
    }

    /**
     * 新增用户认证
     */
    @PostMapping
    public Result add(@RequestBody AccountAuthentication accountAuthentication)
    {
        return Result.success(accountAuthenticationService.insertAccountAuthentication(accountAuthentication));
    }
    /**
     * 智能审核
     */
    @PostMapping("/smartAudit")
    public Result smartAudit(@RequestBody AccountAuthentication accountAuthentication)
    {
        return Result.success(accountAuthenticationService.smartAudit(accountAuthentication));
    }

    /*
     * 修改用户认证
     */
    @PutMapping
    public Result  edit(@RequestBody AccountAuthentication accountAuthentication)
    {
        return Result.success(accountAuthenticationService.updateAccountAuthentication(accountAuthentication));
    }


    /**
     * 根据userType查询用户认证规则
     */
    @GetMapping(value = "/rule")
    public Result getRule(@RequestParam Integer userType)
    {
        return Result.success(accountAuthenticationService.selectCertificationRulesRule(userType));
    }
    /**
     * 编辑查询用户认证规则
     */
    @PutMapping(value = "/rule")
    public Result editRule(@RequestBody CertificationRules rules)
    {
        return Result.success(accountAuthenticationService.updateCertificationRulesRule(rules));
    }




}
